//-------------------------------------------------------------------
//	Copyright (c) 2010-2012  Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_SCENE_INTERFACE_H
#define _UX_SCENE_INTERFACE_H

#include <Includes.h>
#include "../../Systems/Config/CConfig.h"

namespace Engine
{
namespace Scene
{

	//
	// Scene Base Object interface
	//

	class ISceneBaseObject
	{
	public:
		virtual void				 Free() = 0;
		virtual e_scene_object::type GetType() const = 0;
		virtual const string &		 GetTypeName() const = 0;
	};



	//
	// Scene Object Event Listener
	//

	template <typename Message>
	class ISceneObjectEventListener : public ISceneBaseObject
	{
	public:
		// return true if message are request and process complite successfuly
		virtual bool  ProcessMessage(Message &) = 0;
	};



	//
	// Scene Node Component interface
	//
	
	template <typename Message>
	class ISNComponent : public ISceneObjectEventListener< Message >
	{
	protected:
		virtual ~ISNComponent() {}

	public:
		virtual bool  GetMetaIterator(CMetaSetIterator *&) = 0;

		virtual e_component::type		GetComponentBits()	const	{ return e_component::UNKNOWN; }
		virtual e_scene_object::type	GetType()			const	{ return e_scene_object::COMPONENT; }
	};



	//
	// Scene Node Interface
	//
	
	template <	typename Message,
				typename CM  /*component message*/ >

	class ISceneNode : public ISceneObjectEventListener< Message >
	{
	protected:
		virtual ~ISceneNode() {}

	public:
		virtual void  MessageToComponents(CM &) = 0;
		virtual bool  GetMetaIterator(CMetaSetIterator *&) = 0;
		virtual bool  GetComponent(e_component::type, ISNComponent<CM> *&) = 0;

		virtual e_scene_object::type	GetType() const		{ return e_scene_object::NODE; }
	};
	


	//
	// Scene System interface
	//

	template <typename Message>
	class ISceneSystem : public ISceneObjectEventListener< Message >
	{
	protected:
		virtual ~ISceneSystem() {}

	public:
		virtual e_component::type		GetComponentBits()	const	{ return e_component::UNKNOWN; }	// managed components bits
		virtual e_scene_object::type	GetType()			const	{ return e_scene_object::SYSTEM; }
	};



	//
	// Scene Interface
	//

	template <	typename NM   /*node message*/,
				typename CM   /*component message*/,
				typename SM   /*system message*/,
				typename ScM  /*scene message*/ >

	class IScene : public ISceneObjectEventListener< ScM >
	{
	public:
		//typedef IScene< NM, CM, SM, ScM >	Tthis;
		typedef ISceneNode< NM, CM >		ISceneNode;
		typedef ISceneSystem< SM >			ISceneSystem;
		typedef ISNComponent< CM >			ISceneNodeComponent;

	protected:
		virtual ~IScene() {}

	public:
		virtual void  AddNode(ISceneNode *) = 0;
		virtual void  RemoveNode(ISceneNode *) = 0;
		virtual bool  GetNode(const string &, ISceneNode *&) = 0;

		virtual void  AddSystem(ISceneSystem *) = 0;
		virtual void  RemoveSystem(ISceneSystem *) = 0;
		virtual bool  GetSystem(const string &, ISceneSystem *&) = 0;

		virtual void  Destroy() = 0;
		
		virtual e_scene_object::type	GetType() const		{ return e_scene_object::SCENE; }
	};

//-------------------------------------------------------------------

}	// Scene
}	// Engine

#endif	// _UX_SCENE_INTERFACE_H